package com.cmcc.aregister.ui.adapter;

import com.cmcc.aregister.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter
{
    private int total;
    private ImageView[] imgItems;
    private int[] menu_image = { R.drawable.menu_register_selecter,
        R.drawable.menu_hospital_selecter, R.drawable.menu_center_selecter,
        R.drawable.menu_guide_selecter, R.drawable.menu_more_selecter };

    private int[] unselectImages = { R.drawable.menu_register,
        R.drawable.menu_hospital, R.drawable.menu_center,
        R.drawable.menu_guide, R.drawable.menu_more };
    private int[] selectedImages = { R.drawable.menu_register_press,
        R.drawable.menu_hospital_press, R.drawable.menu_center_press,
        R.drawable.menu_guide_press, R.drawable.menu_more_press };

    public ImageAdapter(Context context, int total)
    {
        this.total = total;
        imgItems = new ImageView[total];
        for (int i = 0; i < total; i++)
        {
            imgItems[i] = new ImageView(context);
            imgItems[i].setImageResource(menu_image[i]);
        }
    }

    public int getCount()
    {
        return total;
    }

    public Object getItem(int position)
    {
        return position;
    }

    public long getItemId(int position)
    {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        return imgItems[position];
    }

    public void setFouse(int index)
    {

        imgItems[index].setImageResource(selectedImages[index]);
    }

    public void setNoSelect(int index)
    {
        if (index == -1)
        {
            return;
        }
        imgItems[index].setImageResource(unselectImages[index]);
    }
}